package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.regulatorDevice.RegulatorDeviceGetModel;
import com.hzhr.iot.device.service.RegulatorDeviceService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "RegulatorDevice", description = "调压设备")
@RestController
@RequestMapping(value = "")
public class RegulatorDeviceController extends BaseController {
    @Autowired
    RegulatorDeviceService regulatorDeviceService;

    //region /regulator-devices GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询登录管辖范围内的调压设备", notes="查询登录管辖范围内的调压设备  \n步骤 :  \n1. 查询调压设备 :  \n根据条件参数查询采集设备(COLLECT_DEVICE)对象集合collectDeviceList_1，  \n额外筛选规则如下：  \n          (1) collectDeviceList_1[i].manageUserId = 登录用户.userId;  \n          (2) collectDeviceList_1[i].categoryCode = REGULATOR_BOX or USER_REGULATOR_TANK or SOURCE_REGULATOR_TANK；  \n2. 返回信息 :  \n根据collectDeviceList_1及条件参数生成结果对象result并返回，  \n其中，result.modelList[i]或result.model的managementName、subCompanyName属性的设置规则如下：  \n          根据result.modelList[i]或result.model的deptId属性以GLOBAL方式调用“查询部门”服务(user-service: /depts GET)，  \n          获取到对应部门模型的managementName、subCompanyName属性进行设置；  \nRegulatorDeviceModel.qrCode的设置规则如下：  \n          RegulatorDeviceModel.qrCode = {'code' : RegulatorDeviceModel.code, 'categoryCode' : RegulatorDeviceModel.categoryCode}  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_managementName", value = "是否展示管理站名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_subCompanyName", value = "是否展示分公司名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where regulatorDevice.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_code", value = "筛选条件 : where regulatorDevice.code = #{equal_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_code", value = "筛选条件 : where regulatorDevice.code like #{like_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_categoryCode", value = "筛选条件 : where regulatorDevice.categoryCode = #{equal_categoryCode}",required = true, dataType = "string", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_managementName", value = "是否展示管理站名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_subCompanyName", value = "是否展示分公司名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_is_paging", value = "是否分页", defaultValue = "false",required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where regulatorDevice.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_code", value = "筛选条件 : where regulatorDevice.code = #{_equal_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_code", value = "筛选条件 : where regulatorDevice.code like #{_like_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_categoryCode", value = "筛选条件 : where regulatorDevice.categoryCode like #{_equal_categoryCode}",required = true, dataType = "string", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/regulator-devices", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<RegulatorDeviceGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDeviceGetModel responseBody = regulatorDeviceService.get(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /v1/regulator-devices GET
    //region swagger响应码 : get1
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get1
    @ApiOperation(value="查询登录用户管辖范围下的的调压设备", notes="查询登录用户管辖范围下的的调压设备  \n简介 : 查询登录用户管辖范围下的的调压设备  \n步骤 :  \n1. 查询调压设备 :  \n根据条件参数查询采集设备(COLLECT_DEVICE)对象集合collectDeviceList_1，  \n额外筛选规则如下：  \n          (1) collectDeviceList_1[i].resourceCode like 登录用户.userCode + '%';  \n          (2) collectDeviceList_1[i].categoryCode = REGULATOR_BOX or USER_REGULATOR_TANK or SOURCE_REGULATOR_TANK；  \n2. 返回信息 :  \n根据collectDeviceList_1及条件参数生成结果对象result并返回，  \n其中，result.modelList[i]或result.model的managementName、subCompanyName属性的设置规则如下：  \n          根据result.modelList[i]或result.model的deptId属性以GLOBAL方式调用“查询部门”服务(user-service: /depts GET)，  \n          获取到对应部门模型的managementName、subCompanyName属性进行设置；  \nRegulatorDeviceModel.qrCode的设置规则如下：  \n          RegulatorDeviceModel.qrCode = {'code' : RegulatorDeviceModel.code, 'categoryCode' : RegulatorDeviceModel.categoryCode}  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get1
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_managementName", value = "是否展示管理站名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_subCompanyName", value = "是否展示分公司名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where RegulatorDeviceModel.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_code", value = "筛选条件 : where RegulatorDeviceModel.code = #{equal_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_code", value = "筛选条件 : where RegulatorDeviceModel.code like #{like_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_categoryCode", value = "筛选条件 : where RegulatorDeviceModel.categoryCode = #{equal_categoryCode}",required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_deptId", value = "筛选条件 : where RegulatorDeviceModel.deptId = #{equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "like_installAddress", value = "筛选条件 : where RegulatorDeviceModel.installAddress like % + #{like_installAddress} + %",required = false, dataType = "string", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_managementName", value = "是否展示管理站名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_subCompanyName", value = "是否展示分公司名称", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_is_paging", value = "是否分页", defaultValue = "true",required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where COLLECT_DEVICE.ID = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_code", value = "筛选条件 : where COLLECT_DEVICE.CODE = #{_equal_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_code", value = "筛选条件 : where COLLECT_DEVICE.CODE like #{_like_code}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_categoryCode", value = "筛选条件 : where COLLECT_DEVICE.CATEGORY_CODE like #{_equal_categoryCode}",required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_deptId", value = "筛选条件 : where COLLECT_DEVICE.DEPT_ID = #{_equal_deptId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_like_installAddress", value = "筛选条件 : where COLLECT_DEVICE.INSTALL_ADDRESS like % + #{_like_installAddress} + %",required = false, dataType = "string", paramType = "query"),

    })
    //endregion
    //region 请求 : get1
    @RequestMapping(value = "/v1/regulator-devices", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<RegulatorDeviceGetModel> get1(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDeviceGetModel responseBody = regulatorDeviceService.get1(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
    }
    //endregion
}


































































































































































